/** 
  实习需求报名
*/
<template>
  <div>
      <condition-card @reset="reset" @search="onSubmit" label-position="right" label-width="150px">
        <el-row :gutter="24" style="height: 50px;">
          
          <el-col :span="8">
              <el-form-item :label="$t('requirement.internship')">
                <el-input v-model="queryForm.condition.baseName"></el-input>
              </el-form-item>
          </el-col>
          <el-col :span="8">
              <el-form-item :label="$t('graduate.college')">
                <DictSelect v-model="queryForm.condition.collegeAcademy" filterable @change="collegeChange" :data="options.title" :plzSelect="true"></DictSelect>
                  
              </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('graduate.major')">
           
              <el-select collapse-tags  v-model="queryForm.condition.majorList" multiple filterable clearable  style="width: 100%">
                <el-option
                    v-for="item in options.profession"
                    :key="item.code"
                    :label="item.name"
                    :value="item.code">
                </el-option>
              </el-select>
            </el-form-item>
            
          </el-col>
          <el-col :span="8">
              <el-form-item :label="$t('requirement.states')">
                <el-select v-model="queryForm.condition.status" clearable style="width: 100%">
                  <el-option v-for="item in statusList" :key='item.value' :label="item.label" :value="item.value"> </el-option>
                  <!-- <el-option label="学校审核" :value="1"> </el-option>
                  <el-option label="已审核" :value="2"> </el-option>
                  <el-option label="已驳回" :value="3"> </el-option> -->
                </el-select>
                <!-- <el-select v-model="queryForm.condition.isEnabled" clearable style="width: 100%">
                  <el-option label="启用" :value="1"> </el-option>
                  <el-option label="停用" :value="0"> </el-option>
                </el-select> -->
              </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('requirement.workplace')">
              <el-input v-model="queryForm.condition.workAddress"></el-input>
              <!-- <el-select v-model="queryForm.condition.isEnabled" clearable style="width: 100%">
                <el-option label="启用" :value="1"> </el-option>
                <el-option label="停用" :value="0"> </el-option>
              </el-select> -->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('requirement.declarati')" size="small" >
              <el-date-picker
                :placeholder="$t('internship.pleaseSelect')"
                style="width: 100%"
                v-model="queryForm.condition.applyTimeStartStr"
                :picker-options="pickerOptionsStart"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </el-form-item>
           
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('requirement.reporti')" size="small" >
              <el-date-picker
                :placeholder="$t('internship.pleaseSelect')"
                style="width: 100%"
                v-model="queryForm.condition.applyTimeEndStr"
                :picker-options="pickerOptionsEnd"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('graduate.semester')">
              <CalendarSelect v-model="useConfigParam" @load-done="loadDone" @input='changeInput'></CalendarSelect>
            </el-form-item>
          </el-col>
        </el-row>
      </condition-card>
      <el-card shadow="never" v-loading="loading" body-style="padding: 24px;" class="card-margin">
        <h1 class="condition-title">{{$t('requirement.registration')}}</h1>
        <!-- <div class="float-left associated-conditional-input">
          <KeywordInput v-model="queryForm.condition.name" :placeholder="$t('mainbase.pleasesSearch')"
            @enter="onSubmit"/>
        </div> -->
        <div class="edu-opertion-bar sub-title">
          <div class="float-right" style="display: flex;">
            <!-- <el-button @click="blockUp">{{$t('internship.blockUp')}}</el-button>
            <el-button  @click="startUsin">{{$t('internship.startUsin')}}</el-button> -->
            <!-- <el-dropdown placement='bottom-start' trigger="click" @command="leadFile">
              <el-button type="primary">{{$t('internship.lead')}}<i class="el-icon-arrow-down el-icon--right"></i></el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="导入">{{$t('internship.lead')}}</el-dropdown-item>
                <el-dropdown-item command="下载">{{$t('internship.download')}}</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown> -->
            <el-upload 
              class="upload-demo"
              action="/api/practiceservice/specialist/import" 
              
              :auto-upload="true"
              style="display: none;"
              >
              <span slot="trigger" ref="importBtn">{{$t('requirement.selectFile')}}</span>
              <!--:data="category" <el-button size="small" ref='importBtn' type="primary">点击上传</el-button> -->
              <!-- :on-preview="handlePreview"
              :on-remove="handleRemove"
              :before-remove="beforeRemove"
              :on-exceed="handleExceed"
              :file-list="fileList"<div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div> -->
            </el-upload>
            
            <el-button style="margin-left:10px" type="primary" v-if='deriveBtn' @click="exportFile">{{$t('internship.derive')}}</el-button>
          
            <el-button type="primary" @click="exportAdd" v-if='addBtn'>{{$t('graduate.add')}}</el-button>
           
          </div>
        </div>
        <el-selfEduTable :pagination="false" ref='expertsInfoChoose' :getRowKey="getRowKey" :tooltipEffect="tooltipEffect" stripe :data="dataList" size="mini" @selection-change="handleSelectionChange">
        
          <edu-table-column :label="$t('graduate.semester')" prop="calendarName"></edu-table-column>
          <edu-table-column :label="$t('requirement.internship')" prop="baseName" width='120px'></edu-table-column>
          <edu-table-column :label="$t('requirement.namePost')" prop="positionName">
            <!-- <template slot-scope="props">
              <span v-if="props.row.sex == '2'">女</span>
              <span v-if="props.row.sex == '1'">男</span>
            </template> -->
          </edu-table-column>
          <edu-table-column :label="$t('requirement.college')" prop="collegeAcademy">
            <template slot-scope="scope">
              {{scope.row.collegeAcademy | collegeAcademyList(options.title)}}
            </template>
          </edu-table-column>
          <edu-table-column :label="$t('requirement.major')" prop="major">
            <template slot-scope="scope">
              {{scope.row.major | collegeAcademy(options.faculty)}}
              <!-- {{dataFormajor}} -->
            </template>
          </edu-table-column>
          <edu-table-column :label="$t('requirement.nameJobs')" prop="personNum">
          </edu-table-column>
          <edu-table-column :label="$t('requirement.enrollment')" prop="acceptPersonNum"></edu-table-column>
          <edu-table-column :label="$t('requirement.workplace')" prop="workAddress">
             <!-- <template slot-scope="scope">
               <div class="is-enabled-container">
                <el-button v-if="scope.row.isEnabled === 0" type="danger" plain>{{ scope.row.isEnabled | isEnabled }}</el-button>
                <el-button v-else type="success" plain>{{ scope.row.isEnabled | isEnabled }}</el-button>
              </div>
            </template> -->
          </edu-table-column>
          <edu-table-column :label="$t('requirement.treatment')" prop="treatment"></edu-table-column>
          <edu-table-column :label="$t('requirement.workDate')" prop="workTimeStart">
            <template slot-scope="props">
              {{props.row.workTimeStart}}/{{props.row.workTimeEnd}}
            </template>
          </edu-table-column>
          <edu-table-column :label="$t('requirement.theTime')" prop="applyTimeStart">
            <template slot-scope="props">
              {{props.row.applyTimeStart}}/{{props.row.applyTimeEnd}}
            </template>
          </edu-table-column>
          <edu-table-column :label="$t('requirement.states')" prop="states">
            <template slot-scope="props">
              
              {{props.row.status | collegeAcademyList(statusList)}}
              <!-- <span v-if="props.row.status == 0">草稿</span>
              <span v-if="props.row.status == 1">学校审核</span>
              <span v-if="props.row.status == 2">已审核</span>
              <span v-if="props.row.status == 3">已驳回</span> -->
            </template>
          </edu-table-column>
          <edu-table-column :label="$t('graduate.operate')" fit align='center' width="180">
            <template slot-scope="props">
              <el-row type="flex" class="row-bg" justify="center">
                <el-button type="text" @click="checkOutline(props.row)" v-if='auditBtn&&props.row.status == 1&&personas=="教务员"'>{{$t('requirement.audit')}}</el-button>
                <!-- personas -->
                <div v-if='applyForBtn'>

                  <el-button type="text" @click="applyFor(props.row)" v-if="personas=='学生'&&props.row.status == 2" >{{$t('requirement.applyFor')}}</el-button>
                </div>
                <el-button type="text" @click="editOutline(props.row)" v-if='editBtn&&props.row.status==0||props.row.status==3&&personas=="基地管理员"'>{{$t('requirement.edit')}}</el-button>
                <!--  -->
                <el-button type="text" @click="specialEdit(props.row)" v-if='detailsBtn'>{{$t('requirement.details')}}</el-button>
                <el-button type="text" @click="removeOutline(props.row)" v-if='removeBtn&&props.row.status==0||props.row.status==3&&personas=="基地管理员"'>{{$t('requirement.remove')}}</el-button>
                <el-button type="text" @click="allowedOutline(props.row)" v-if='collegeAllowedBtn&&props.row.status == 2'>{{$t('requirement.allowed')}}</el-button>
              </el-row>
            </template>
          </edu-table-column>
        </el-selfEduTable>
        <el-row type="flex" class="row-bg" justify="end">
          <el-col>
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="queryForm.pageNum_"
                :page-sizes="[20, 40, 80, 100]"
                :page-size="queryForm.pageSize_"
                layout="total, sizes, prev, pager, next, jumper"
                :total="queryForm.total_"
                style="float:right;margin-top:10px"
              ></el-pagination>
          </el-col>
        </el-row>
      </el-card>
      
      <edu-export-dialog
        :disabled="exportButton"
        :title="$t('message.prompt')"
        ref="downloadRef"
        :data="exportResult">
      </edu-export-dialog>
  </div>
</template>
<script>
import { queryDic } from "common/src/api/dictionary";
import UTILS from "common/src/utils/utils";
import selfEduTable from 'common/src/views/graduateStudent/common/selfEduTable';
import graduateStudent from 'common/src/api/graduateStudent/graduateStudent';
// import SchoolCalendarApi from "common/src/api/calendars";
// import graduateOuline from "./graduateOuline";
// import detailsTempList from "./detailsTempList";
export default {
  components: {
    'el-selfEduTable': selfEduTable
  },
  data () {
    return {
      multipleSelection: [],
      provideData: {}, // 提供子组件表格数据
      useConfigParam: '',
      useConfigParamList: '',
      queryForm: {
        pageNum_: 1,
        pageSize_: 20,
        total_: 0,
        condition:{
          "baseName": "",
          "collegeAcademy": "",
          "collegeAcademyList": [],
          "majorList": [],
          "status": "",
          "workAddress": "",
          "applyTimeStartStr": "",
          "applyTimeEndStr": ""
        }
      },
      addBtn: false, 
      deriveBtn: false, 
      auditBtn: false, 
      applyForBtn: false, 
      editBtn: false, 
      detailsBtn: false, 
      removeBtn: false, 
      collegeAllowedBtn: false,  // 学院填报
      options: {
        title: [],
        TrainingLevel: [],
        degreeType: [],
        formLearning: [],
        faculty: [],
        profession: [],
        trainingCategory: []
      },
      pickerOptionsStart: {
        disabledDate: time => {
          let endDateVal = this.queryForm.condition.applyTimeEndStr;
          if (endDateVal) {
            // return time.getTime() > endDateVal;
            return time.getTime() >= new Date(endDateVal).getTime();
          }
        }
      },
      pickerOptionsEnd: {
        disabledDate: time => {
          let beginDateVal = this.queryForm.condition.applyTimeStartStr;
          if (beginDateVal) {
            // return time.getTime() < beginDateVal;
            return time.getTime() <= new Date(beginDateVal).getTime()- 86400000;
          }
        }
      },
      queryList: {
        calendarId: '',
        faculty: '',
        status: '',
        course: ''
      },
      rules: {
       
      },
      personas: '',
      rulesForm: {
       
      },
      statusList: [
        { label: "草稿", value: 0},
        { label: "学院审核", value: 1},
        { label: "已审核", value: 2},
        { label: "已驳回", value: 3}
      ],
      dataList: [],
      loadList: [],
      auths: [],
      breadPath: {
        label: this.$t('graduate.graduate'),
        key: "1",
        children: [
          {
            key: "2",
            label: ""
          }
        ]
      },
    }
  },
  watch: {
    auths: {
      handler: function(newVal) {
        if (newVal && Array.isArray(newVal) && newVal.length > 0) {
          newVal.some(item => {
            if (item.authCode === 'internshipDemand-addBtn') {
            // 新增
              this.addBtn = true;
            }
            if (item.authCode === 'internshipDemand-editBtn') {
              // 编辑
              this.editBtn = true;
            }
            if (item.authCode === 'internshipDemand-collegeAllowedBtn') {
              // 学院填报
              this.collegeAllowedBtn = true;
            }
            if (item.authCode === 'internshipDemand-detailsBtn') {
              // 详情
              this.detailsBtn = true;
            }
            if (item.authCode === 'internshipDemand-deriveBtn') {
              // 导出
              this.deriveBtn = true;
            }
            if (item.authCode === 'internshipDemand-applyForBtn') {
              // 申请
              this.applyForBtn = true;
            }
            if (item.authCode === 'internshipDemand-auditBtn') {
              // 审核
              this.auditBtn = true;
            }
            if (item.authCode === 'internshipDemand-removeBtn') {
              // 删除
              this.removeBtn = true;
            }
          });
        }
      },
      deep: true,
      immediate: true
    }
  },
  created() {
    this.getCurrentRole();
    if (localStorage.getItem("sessiondata")) {
      if (JSON.parse(localStorage.getItem("sessiondata")).auths) {
        this.auths = JSON.parse(localStorage.getItem("sessiondata")).auths;
      }
    }
    // this.auths = JSON.parse(localStorage.getItem("sessiondata")).auths;
    // this.auths.some(item => {
    //   if (item.authCode === 'internshipDemand-addBtn') {
    //     // 新增
    //     this.addBtn = true;
    //   }
    //   if (item.authCode === 'internshipDemand-editBtn') {
    //     // 编辑
    //     this.editBtn = true;
    //   }
    //   if (item.authCode === 'internshipDemand-collegeAllowedBtn') {
    //     // 学院填报
    //     this.collegeAllowedBtn = true;
    //   }
    //   if (item.authCode === 'internshipDemand-detailsBtn') {
    //     // 详情
    //     this.detailsBtn = true;
    //   }
    //   if (item.authCode === 'internshipDemand-deriveBtn') {
    //     // 导出
    //     this.deriveBtn = true;
    //   }
    //   if (item.authCode === 'internshipDemand-applyForBtn') {
    //     // 申请
    //     this.applyForBtn = true;
    //   }
    //   if (item.authCode === 'internshipDemand-auditBtn') {
    //     // 审核
    //     this.auditBtn = true;
    //   }
    //   if (item.authCode === 'internshipDemand-removeBtn') {
    //     // 删除
    //     this.removeBtn = true;
    //   }
    // });
    // graduateStudent.getPracticeRoleBySession().then(res => {
    //   // console.log(res, 'sdfdsf');
      
    // });
  },
  filters: {
    collegeAcademyList(val, array) {
      let str = "";
      for (let item of array) {
        if (val == item.value) {
          str = item.label;
        }
      }
      return str;
    },
    collegeAcademy(val, array) {
      let list = [];
      let str = [];
      let data = '';
      let label = '';
      data = val.indexOf(',');
      if (data ==-1) {
        for (let item of array) {
          if (val == item.value) {
            label = item.label;
          }
        }
        return label;
        
      } else {
        list = val.split(',');
        list.forEach(el => {
          array.forEach(ele => {
            if (el == ele.value) {
              str.push(ele.label);
            }
          });
        });
        return str.join();
      }
    }
  },
  mounted() {
    this.getOptions();
    // this.postInternshipBase(this.queryForm);
    // console.log(this.mockUser, 'sdfds110', this.currentUser);
    
  },
  methods: {
    postInternshipBase(date) {
      graduateStudent.positionNeedsRequirement(date).then(res => {
        // console.log(res, 'sdkjf');getCommonCurrentRole
        // this.queryForm.pageNum_ = res.data.current;
        // this.queryForm.pageSize_ = res.data.size;
        this.queryForm.total_ = res.data.total;
        this.dataList = res.data.records;
      });
    },
    getCurrentRole() {
      graduateStudent.getCommonCurrentRole().then(res =>{
        // console.log(res);
        this.personas = res.data;
        // "data":"管理员/教务员/导师/学生/基地管理员/实践专家/校外导师"
      });
    },
    getOptions() {
      // 筛选条件字典查询
      let data = {
        lang: this.$store.getters.language || "cn",
        type: "allChild",
        keys: ['X_YX', 'G_ZY']
      };
      queryDic(data).then(res => {
        UTILS.fillSelect(
          {
            title: "X_YX",
            faculty: "G_ZY"
          },
          res.data,
          this.options
        );
        // console.log(this.options);
        
      });
    },
    getRowKey(row) {
      return row.id;
    },
    // 学院选择
    collegeChange(val) {
      this.queryForm.condition.majorList = [];
      if (val.length > 0) {
        let collegeList = [];
        collegeList.push(val);
        graduateStudent.getDegreeByCollege(collegeList).then(res => {
          this.options.profession = res.data;
        });
      } else {
        this.options.profession = [];
      }
      this.queryForm.condition.collegeAcademyList = [];
      if (val) {

        this.queryForm.condition.collegeAcademyList.push(val);
      } else {
        this.queryForm.condition.collegeAcademyList = [];
      }
    },
    changeClick(val) {
      
    },
    // 导入
    leadFile(command) {
      // console.log(command);
      if (command === '导入') {
        this.channel = true;
        this.$refs.importBtn.click();
      } else if (command === '下载') {
        graduateStudent.downloadTemplate().then(res => {
          this.$message(this.$t('internship.successfully'));
        });
      }
    },
    // 轮询直到获取key值的接口返回
    cycleToGetKey() {
      setTimeout(() => {
        let currentIds = [];
        if (this.multipleSelection.length > 0) {
          this.multipleSelection.forEach((element) => {
            currentIds.push(element.id);
          });
        }
        graduateStudent.specialist({
          "templateName": this.queryForm.condition.department,
          "baseLevel": this.queryForm.condition.proTitle,
          "isEnabled": this.queryForm.condition.isEnabled,
          "name": this.queryForm.condition.name,
          "sex": this.queryForm.condition.sex,
          // "category": this.queryForm.condition.category,
          "selectRowIds": currentIds
        }).then(res => {
          if (res.success) {
            this.$refs.downloadRef.close();
            this.exportButton = false;
            this.normalDelayRequest(res.key, res.msg);
          } else {
            this.cycleToGetKey();
          }
        });
      }, 3000);
    },
    // 导出异步
    delayRequest(key, name) {
      setTimeout(() => {
        graduateStudent.downloadGetKey(key, name).then(res => {
          this.exportResult = res.data;
          if (res.code == 200 && res.data.status) {
            this.exportButton = false;
            let path =
              '/api/practiceservice/export/file?path=' +
              res.data.path + '&name=' + name;
            // window.open(path);
            window.location.href = path;
            this.$message.success(this.$t('result.exportSuccessfully'));
            this.$refs.downloadRef.close();
          } else {
            this.delayRequest(key, name);
          }
        });
      }, 3000);
    },
    // Normal导出异步
    normalDelayRequest(key, name) {
      setTimeout(() => {
        graduateStudent.downloadGetKey(key).then(res => {
          this.exportResult = res.data;
          if (res.code == 200 && res.data.status) {
            this.exportButton = false;
            let path =
              '/api/practiceservice/export/file?path=' +
              res.data.path + '&name=' + name;
            // window.open(path);
            window.location.href = path;
            this.$message.success(this.$t('result.exportSuccessfully'));
            this.$refs.downloadRef.close();
          } else {
            this.delayRequest(key, name);
          }
        });
      }, 3000);
    },
    // 导出
    exportFile(command) {
      // 1、第一步：调该接口，获取key值以及msg中的文件名
      // 2、第二步：将key值放入接口传参
      // 3、第三步：传入path值以及name(msg中的文件名)值，下载文件
      let list = [];
      let data = [];
      let dataList = JSON.parse(JSON.stringify(this.multipleSelection));
      if (dataList.length > 0) {
        dataList.forEach(el => {
          this.options.title.forEach(ele => {
            if (el.collegeAcademy === ele.value) {
              el.collegeAcademy = ele.label;
            }
          });
          list = el.major.split(',');
          this.options.faculty.forEach(ele => {
            list.forEach(eld => {
              if (eld === ele.value) {
                data.push(ele.label);
              }
            });
          });
          el.major = data.join();
          this.statusList.forEach(ele => {
            if (el.status === ele.value) {
              el.status = ele.label;
            }
          });
          el.applyTime = el.applyTimeStart + '/' + el.applyTimeEnd;
          el.workTime = el.workTimeStart + '/' + el.workTimeEnd;
        });
      } else {
        dataList = [];
      }
      let obj = {
        positionNeedsExportDTOList: dataList,
        needsSearchCondition: this.queryForm.condition
      };
      graduateStudent.exportNeedsList(obj).then(() => {
        this.$message(this.$t('internship.successfully'));
      });
      
    },
    // 特殊编辑关闭
    editClose() {
      this.$refs.editform.cancelDialog();
    },
    // 特殊编辑保存
    editrmForm(param) {

    },
    // 编辑
    exportEdit() {
      this.showDate = false;
    },
    // 搜索/筛选
    onSubmit() {
      this.loadList.forEach(el => {
        if (el.id === this.useConfigParam) {
          this.queryForm.condition.calendarName = el.fullName;
        }
      });
      this.queryForm.pageNum_ = 1;
      this.postInternshipBase(this.queryForm);
    },
    loadDone(data, val) {
      this.loadList = data;
      this.loadList.forEach(el => {
        if (el.id === val) {
          this.queryForm.condition.calendarName = el.fullName;
          this.calendarName = el.fullName;
          this.useConfigParamList = val;
        }
      });
      this.postInternshipBase(this.queryForm);
      // this.postInternshipSet(this.queryForm);
    },
    changeInput(val) {
      this.loadList.forEach(el => {
        if (el.id === val) {
          this.queryForm.condition.calendarName = el.fullName;
        }
      });
    },
    // 停用
    blockUp() {},
    // 启用
    startUsin() {},
    // 批量审核
    batchReview() {},
    // 新增
    exportAdd() {
      this.$router.push({
        path: '/internshipDemandAdd',
        query: { 
          data: this.queryForm,
          title: 'add'
        }
      });
      // this.title = this.$t('internship.applicaInternship');
      // this.dataProp = '新增';
      // this.dataObjit = {};
      // this.addflag = true;
    },
    // 取消
    changeClose(param) {
      this.addflag = param;
    },
    // 取消
    beforeClose(param) {
      this.$refs.addform.cancelDialog();
    },
    tableClose() {
      this.tableFlag = false;
    },
    // 新增保存（编辑保存）
    addrmForm(param, data) {
      if (this.dataProp === '编辑') {
        if (data === 'conserve') {
          graduateStudent.internshipPreservat(param).then(res => {
            this.$message.success(this.$t('internship.successfully')); 
            
            this.addflag = false;
            this.queryForm.pageNum_ = 1;
            this.postInternshipBase(this.queryForm);
            this.$refs.addform.confirmInner();
          });
        } else {
          graduateStudent.internshipEdit(param).then(res => {
            // console.log(res, 'sdkjf');
            this.$message.success(this.$t('internship.successfully')); 
            this.addflag = false;
            this.queryForm.pageNum_ = 1;
            this.postInternshipBase(this.queryForm);
            this.$refs.addform.confirmInner();
          });
        }
      } else if (this.dataProp === '新增') {
        if (data === 'conserve') {
          graduateStudent.internshipPreservat(param).then(res => {
            this.$message.success(this.$t('internship.successfully')); 
            
            this.addflag = false;
            this.queryForm.pageNum_ = 1;
            this.postInternshipBase(this.queryForm);
            this.$refs.addform.confirmInner();
          });
        } else {
          graduateStudent.internshipAdd(param).then(res => {
            this.$message.success(this.$t('internship.successfully')); 
            
            this.addflag = false;
            this.queryForm.pageNum_ = 1;
            this.postInternshipBase(this.queryForm);
            this.$refs.addform.confirmInner();
          });
        }
        
      }
      
    },
    addCancel(data) {
      this.addflag = data;
    },
    
    getListData() {
      undergraduategraduateApi.getgraduateList(this.queryForm).then((res) => {
        this.dataList = res.data.list;
        this.queryForm.total_ = res.data.total_;
      })
    },
    initOptions() {
      innovativeApi.getAllFaculty().then(res => {
        this.options.facultys = res.data.map(item => {
          return {
            label: item.deptName,
            value: item.deptCode
          }
        });
      })
    },
    // async getCurrentTermCalendar(){
    //   return await SchoolCalendarApi.currentTermCalendar();
    // },
    handleSelectionChange(val) {
      this.multipleSelection = val;
     
    },
    // 详情
    specialEdit(row) {
      this.$router.push({
        path: '/internshipDemandDetails',
        query: {
          data: this.queryForm,
          row: row
        }
      });
    },
    // 审核
    checkOutline(row) {
      // this.addflag = true;audit
      this.$router.push({
        path: '/internshipDemandAudit',
        query: {
          data: this.queryForm,
          row: row
        }
      });
      // this.dataObjit = row;
    },
    // 申请
    applyFor(row) {
      this.$router.push({
        path: '/internshipRequirement',
        query: { 
          data: this.queryForm,
          row: row
        }
      });
    },
    // 学院填报
    allowedOutline(row) {
      this.$router.push({
        path: '/internshipDemandAllowed',
        query: {
          data: this.queryForm,
          row: row,
          title: 'allowed'
        }
      });
    },
    // 编辑
    editOutline(row) {
      this.$router.push({
        path: '/internshipDemandAdd',
        query: { 
          data: this.queryForm,
          row: row,
          title: 'edit'
        }
      });
      // this.title = this.$t('graduate.edit');
      // this.dataProp = '编辑';
      // this.mainbase = '专家';
      // this.dataObjit = row;
      // this.addflag = true;
    },
    // 删除
    removeOutline(row) {
      this.$confirm(this.$t('internship.deleteDate'), this.$t('internship.systemPrompt'), {
          confirmButtonText: this.$t('graduate.define'),
          cancelButtonText: this.$t('graduate.cancel'),
          type: 'warning'
        }).then(() => {
          // let list = [];
          // list.push(row.id);
          graduateStudent.getpositionNeedsDelete(row.id).then(res => {
            this.$message({
              type: 'success',
              message: this.$t('internship.successfully')
            });
            this.queryForm.pageNum_ = 1;
            this.postInternshipBase(this.queryForm);
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: this.$t('internship.cancelOpera')
          });          
      });
    },
    // 关闭弹框
    changeProp() {
      this.addflag = false;
    },
    // 查看考核指标表
    indicatorsList() {},
    // 重置
    reset() {
      for (let key in this.queryForm.condition) {
        if (key === 'collegeAcademyList') {
          this.queryForm.condition.collegeAcademyList = [];
        } else if (key === 'majorList') {
          this.queryForm.condition.majorList = [];
        } else {
          this.queryForm.condition[key] = '';
        }
      }
      this.options.profession = [];
      this.useConfigParam = this.useConfigParamList;
      this.queryForm.condition.calendarName = this.calendarName;
      this.$refs.expertsInfoChoose.clearSelection();
      this.queryForm.pageNum_ = 1;
      this.postInternshipBase(this.queryForm);
    },
    // 保存
    conserve() {
      this.addflag = false;
    },
   
    diaCancel() {
      this.$refs['copyTime'].resetFields();
      this.copyDialog = false;
    },
   
    // dialogClose() {
    //   this.copyDialog = false;
    //   this.$refs['copyTime'].resetFields();
    // },
    handleSizeChange(val) {
      this.queryForm.pageSize_ = val;
      this.queryForm.pageNum_ = 1;
      this.postInternshipBase(this.queryForm);
    },
    handleCurrentChange(val) {
      this.queryForm.pageNum_ = val;
      this.postInternshipBase(this.queryForm);
    }
    
  }
  
}
</script>
<style lang="scss" scoped>
.condition-title {
  color: #2b3b4e;
  font-size: 18px;
  line-height: 24px;
  font-weight: bold;
}
  .edu-page-title {
    span {
      line-height: 24px;
      display: inline-block;
      padding-right: 10px;
      font-size: 18px;
      font-weight: bold;
      color: #2b3b4e;
    }
  }
  .sub-title {
    margin: 16px 0;
    font-size: 16px;
    color: #000020;
    letter-spacing: 0;
  }
  .form-item {
    width: 312px;
    height: 32px;
    float: left;
    margin: 0px 10px;
  }
  .inputBox{
    width: 240px!important;height: 32px!important;
  }
  .atooltip{
    background: beige;
    border: black;
  }
</style>
